package ch03.staticProxy;

/**
 * @author Jane
 * @date 2024-03-25 15:14
 */

public class BuyerProxy implements Buy {
  /*  public void setBuyer(Buyer buyer) {
        this.buyer = buyer;
    }*/

    private Buyer buyer;

    public BuyerProxy(Buyer buyer) {
        this.buyer = buyer;
    }

    public void look() {
        for (int i = 0; i < 5; i++) {
            System.out.println(buyer.name + "第" + (i + 1) + "次看房,对比性价比");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

    @Override
    public String pay() {
        //return buyer.name+"全额付款100万,合同已签";
        look();
        String msg = buyer.pay();
        System.out.println(msg);
        tax();
        last();
        return msg;
    }

    public void tax() { //交税
        System.out.println("各种跑腿,证件终于集齐");
        System.out.println("各种税费都已交完");
    }

    public void last() { //交税
        System.out.println("终于可以装修入住了!");
    }

}
